package com.bestcem.xm.ticket.service;

import com.bestcem.xm.common.core.domain.web.ServiceResult;
import com.bestcem.xm.ticket.controller.param.NotificationParam;
import com.bestcem.xm.ticket.controller.vo.NotificationVO;
import com.bestcem.xm.ticket.controller.vo.SimpleIdVO;
import com.bestcem.xm.ticket.controller.vo.wechat.WechatUserInfoVO;
import com.bestcem.xm.ticket.entity.mongo.Notification;
import com.bestcem.xm.ticket.service.dto.mq.NotificationTriggerDTO;

import javax.annotation.Nonnull;
import java.util.List;

/**
 * 预警
 *
 * @author zq.ding <zq.ding@idiaoyan.com>
 * @version v1.0
 * @date 2021/8/23 14:16
 */
public interface TicketNotificationService {

    /**
     * 用问卷Id得到TicketNotification，没有则创建
     *
     * @param surveyId
     * @return 详细信息
     * @author zq.ding <zq.ding@idiaoyan.com>
     * @date 2021/8/23 14:19
     * @date 2022/4/7 12:16 XiaoYunSong 通知提醒新增微信公众号需求 新增 是否开启免打扰/是否开启微信公众号通知
     */
    ServiceResult<NotificationVO> getNotificationBySurveyId(String surveyId);

    /**
     * 根据传入的surveyId和param更新notification
     *
     * @param surveyId
     * @return id
     * @author zq.ding <zq.ding@idiaoyan.com>
     * @date 2021/8/23 17:38
     * @date 2022/4/7 12:16 XiaoYunSong 通知提醒新增微信公众号需求 新增 是否开启免打扰/是否开启微信公众号通知
     */
    ServiceResult<SimpleIdVO> updateNotification(String surveyId, NotificationParam param);

    /**
     * 通过项目id创建通知
     *
     * @param projectId 问卷id
     * @author jy.zhao
     * @date 2021/8/23 16:32
     * @date 2022/4/7 12:16 XiaoYunSong 通知提醒新增微信公众号需求 新增 是否开启免打扰/是否开启微信公众号通知
     */
    @Nonnull
    Notification createDefaultNotification(String projectId);


    /**
     * 触发通知
     *
     * @param notificationTriggerDTO 触发通知dto
     * @author jy.zhao
     * @date 2021/8/26 14:56
     **/
    void triggerNotification(NotificationTriggerDTO notificationTriggerDTO);


    /**
     * 获取通知提醒对应的微信订阅用户
     *
     * @param surveyId 问卷id
     * @return 微信用户列表
     * @author XiaoYunSong <ys.xiao@idiaoyan.com>
     * @date 2022/4/7 10:49
     */
    ServiceResult<List<WechatUserInfoVO>> getNotificationSubscribers(String surveyId);


    /**
     * 新增通知提醒对应的微信订阅用户
     *
     * @param surveyId 问卷id
     * @param openId   微信openId
     * @return 新增成功与否
     * @author XiaoYunSong <ys.xiao@idiaoyan.com>
     * @date 2022/4/7 13:09
     */
    ServiceResult<Boolean> createNotificationSubscriber(String surveyId, String openId);


    /**
     * 移除通知提醒微信订阅用户信息
     *
     * @param surveyId      问卷项目id
     * @param wechatOpenIds 需要移除订阅的微信openId列表
     * @return void
     * @author XiaoYunSong <ys.xiao@idiaoyan.com>
     * @date 2022/4/7 11:30
     */
    ServiceResult<Object> removeNotificationSubscribers(String surveyId, List<String> wechatOpenIds);


    /**
     * 移除微信用户订阅的所有问卷
     *
     * @param openId 微信openId
     * @return void
     * @author XiaoYunSong <ys.xiao@idiaoyan.com>
     * @date 2022/4/11 14:50
     */
    ServiceResult<Object> removeWechatUserSubscription(String openId);
}
